package com.we.tickets.util;

import com.alibaba.fastjson.JSONObject;

import java.util.Comparator;

public class ListComparator implements Comparator<JSONObject> {
    @Override
    public int compare(JSONObject o1, JSONObject o2) {
        float o1_minprice = o1.getFloat("minprice_temp");
        float o2_minprice = o2.getFloat("minprice_temp");

        if (o1_minprice != o2_minprice) {
            return (o1_minprice > o2_minprice) ? 1: -1;
        } else {
            if (o1.getIntValue("passtime_temp") != o2.getIntValue("passtime_temp")) {
                return o1.getIntValue("passtime_temp") - o2.getIntValue("passtime_temp");
            } else {
                return 0;
            }
        }
    }
}
